/*
 * ContentWidget.java
 *
 */

package net.kernub.webcore.client;

import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.LazyPanel;

public class ContentWidget extends LazyPanel
{
	private final Label captionLabel = new Label();

	public ContentWidget()
	{
	}

	public abstract Widget onInitialize();

	public void setCaption( String caption )
	{
		captionLabel.setText( caption );
	}

	@Override
	protected final Widget createWidget()
	{
		Widget widget = onInitialize();

		captionLabel.addStyleName( "" );

		final VerticalPanel panel = new VerticalPanel();
		panel.setWidth( "100%" );
		panel.add( captionLabel );
		panel.add( widget );

		return panel;
	}

	@Override
	protected void onLoad()
	{
		ensureWidget();
	}
};

